import java.util.TreeSet;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-04-18
 * Time:15:32
 */
public class TreeSetDemo02 {
    public static void main(String[] args) {
        //创建集合对象
        TreeSet<Book> ts=new TreeSet<Book>();
        //创建元素对象
        Book s1=new Book("西游记");
        Book s2=new Book("简爱");
        Book s3=new Book("三国演义");

        //将元素对象添加到集合对象中
        ts.add(s1);
        ts.add(s2);
        ts.add(s3);

        //遍历
        for(Book s:ts){
            System.out.print(s.getName()+"  ");
        }
    }
}
